#ifndef _IOEVENTDEF_H_
#define _IOEVENTDEF_H_



#include <util/util.h>

#include <event2/event.h>
#include <event2/event_compat.h>
#include <event2/bufferevent.h>
#include <event2/bufferevent_struct.h>
#include <event2/bufferevent_compat.h>

#include <event2/buffer.h>
#include <event2/event_struct.h>
#include <event2/thread.h>

#include <compat/thread.h>



#define IO_VALUE_ERROR 0

#define ptrnull_value(x, _h_r_) { if(!(x))  return _h_r_; }
#define ptrnull_return(x)		{ if(!(x))  return ; }


#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))


#ifdef __cplusplus

#define uvNameSpaceBegin						namespace iouv {
#define uvNameSpaceEnd							}
#define uvNameSpace								using namespace iouv;


#else 

#define uvNameSpaceBegin	
#define uvNameSpaceEnd		
#define uvNameSpace			


#endif


typedef void(*async_fun_cb)(void *pData);

struct io_ptr {
	unsigned char*		pWritePtr;
	unsigned long		ulWriteLen;
	unsigned char*		pReadPtr;
	unsigned long		ulReadLen;
};

struct io_data {
	void*				pdata;
	unsigned long		uSendId;
	unsigned long		uRecvId;
	async_fun_cb		func;
	async_fun_cb		freefunc;
	async_fun_cb		errorfunc;
	io_ptr				stream;
};



#include "ioallocator.h"
#include "ioeventloop.h"



#endif // _IOEVENTDEF_H_

